package cn.wnco.tool;

public class Tmap {
    private final ThreadLocal<Uinfo> threadLocal;
    private static Tmap tmap = null;

    public static Tmap instance() {
        if (tmap == null) {
            tmap = new Tmap();
        }
        return tmap;
    }

    private Tmap() {
        threadLocal = new ThreadLocal<>();
    }

    public void setContext(Uinfo uInfo) {
        threadLocal.set(uInfo);
    }

    public Uinfo getContext() {
        return threadLocal.get();
    }

    public void clear() {
        threadLocal.remove();
    }

}
